import jsonp from 'common/js/jsonp'
import axios from 'axios'
import {commonParams, options} from './config'
export function getRecommend() {
  const url = 'https://c.y.qq.com/v8/fcg-bin/fcg_first_yqq.fcg'
  const data = Object.assign({}, commonParams, {
    platform: 'yqq',
    loginUin: 0,
    needNewCode: 1,
    page: 'other'
  })
  return jsonp(url, data, options)
}

export function getDiscList() {
  const url = '/api/getDiscList'
  const data = Object.assign({}, commonParams, {
    platform: 'yqq',
    loginUin: 0,
    needNewCode: 0,
    page: 'other',
    ein: '29',
    sin: '0',
    sortId: '5',
    categoryId: '10000000',
    rnd: Math.random(),
    format: 'json'

  })
  console.log(data)
  return axios.get(url, {params: data}).then((res) => {
    return Promise.resolve(res.data)
  })
}

export function getSongList(disstid) {
  const url = '/api/getSongList'
  const data = Object.assign({}, commonParams, {
    disstid,
    type: 1,
    json: 1,
    utf8: 1,
    onlysong: 0,
    nosign: 1,
    pic: 500,
    new_format: 1,
    needNewCode: 1,
    platform: 'h5',
    uin: 0,
    format: 'json'
  })

  return axios.get(url, {params: data}).then((res) => {
    return Promise.resolve(res.data)
  })
}
